﻿//准备ExtJS环境
Ext.require
(
    [
        'Ext.form.field.File',
        'Ext.grid.*',
        'Ext.data.*',
        'Ext.util.*',
        'Ext.state.*',
        'Ext.form.*'
    ]
);

//定义用户表格控件
Ext.define
(
    'MaintainMaterial.Grid',
    {
        extend: 'Ext.grid.Panel',

        //编辑窗体
        win_edit: null,

        //新增窗体
        win_create: null,

        //初始化组件
        initComponent: function ()
        {
            Ext.apply
            (
                this,
                {
                    listeners:
                    {
                        //设置两个指头的滚动
                        render: Common.ScrollableRender
                    },
                    dockedItems:
                    [
                        {
                            xtype: 'toolbar',
                            height: 36,
                            items:
                            [
                                {
                                    iconCls: 'icon-refresh',
                                    text: '刷新',
                                    scope: this,
                                    hidden: false,
                                    tooltip: '刷新数据',
                                    handler: this.onRefreshClick
                                },
                                '-',
                                {
                                    iconCls: 'icon-add',
                                    text: '新增',
                                    scope: this,
                                    hidden: false,
                                    tooltip: '新增养护材料',
                                    handler: this.onAddClick
                                },
                                {
                                    iconCls: 'icon-delete',
                                    text: '删除',
                                    disabled: true,
                                    hidden: false,
                                    itemId: 'button-delete',
                                    scope: this,
                                    tooltip: '删除养护材料',
                                    handler: this.onDeleteClick
                                },
                                {
                                    iconCls: 'icon-edit',
                                    text: '编辑',
                                    itemId: 'button-edit',
                                    disabled: false,
                                    hidden: false,
                                    scope: this,
                                    tooltip: '编辑养护材料',
                                    handler: this.onEditClick
                                },
                                '->',
                                {
                                    iconCls: 'icon-submit',
                                    text: '提交审核',
                                    itemId: 'button-submit',
                                    scope: this,
                                    disabled: true,
                                    hidden: false,
                                    tooltip: '提交审核',
                                    handler: this.onSubmitClick
                                }
                            ]
                        }
                    ]
                }
            );
            this.callParent();
            this.getSelectionModel().on('selectionchange', this.onSelectionChange, this);
        },

        //处理选中养护变化事件
        onSelectionChange: function (selectionModel, selections)
        {
            //判断是否选中养护
            if (selections.length === 0)
            {
                //禁用删除按钮
                this.down('#button-delete').setDisabled(true);
                //禁用编辑按钮
                this.down('#button-edit').setDisabled(true);
                //禁用上传按钮
                this.down('#button-submit').setDisabled(true);
            }
            else
            {
                //获得选中的行
                var selection = this.getView().getSelectionModel().getSelection()[0];

                //启用删除按钮
                this.down('#button-delete').setDisabled(false);
                //启用编辑按钮
                this.down('#button-edit').setDisabled(false);
                //启用上传按钮
                this.down('#button-submit').setDisabled(false);
            }
        },

        //处理删除按钮点击事件
        onDeleteClick: function ()
        {
            //获得数据存储对象
            var store = this.store;

            //获得选中的行
            var selection = this.getView().getSelectionModel().getSelection()[0];

            //判断是否选中行
            if (selection)
            {
                //询问是否确定删除
                Ext.Msg.show
                (
                    {
                        title: '删除养护工作量',
                        width: 320,
                        height: 240,
                        msg: '确定要删除选中的养护材料"' + selection.data.MaintainCode + '"吗?',
                        buttons: Ext.Msg.YESNO,
                        icon: Ext.Msg.QUESTION,
                        fn: function (button)
                        {
                            //判断是否确定删除 
                            if (button == 'yes')
                            {
                                //创建请求对象
                                Ext.Ajax.request
                                (
                                    {
                                        url: Common.MakeAbsoluteUrl('Delete'),
                                        method: HttpMethod.Post,
                                        params: selection.data,
                                        callback: function (options, success, response)
                                        {
                                            //处理错误
                                            if (Common.HandleError(options, success, response))
                                            {
                                                //刷新数据
                                                store.load();
                                            }
                                        }
                                    }
                                );
                            }
                        }
                    }
                );
            }
        },

        //处理刷新按钮点击事件
        onRefreshClick: function ()
        {
            //刷新数据
            this.store.load();
        },

        //处理新增按钮点击事件
        onAddClick: function ()
        {
            //获得数据存储对象
            var store = this.store;

            //判定窗体是否创建
            if (!this.win_create)
            {
                //创建窗体
                this.win_create = new Ext.Window
                (
                    {
                        title: '新增养护材料',
                        maximizable: false,
                        maximized: false,
                        width: 480,
                        height: 540,
                        bodyBorder: false,
                        draggable: true,
                        isTopContainer: true,
                        modal: true,
                        resizable: false,
                        bodyPadding: 0,
                        closeAction: 'hide',
                        closable: false,
                        layout: 'fit',
                        closable: false,
                        fieldDefaults:
                        {
                            labelAlign: 'left',
                            labelWidth: 72,
                            anchor: '100%'
                        },
                        items:
                        [
                            {
                                xtype: 'form',
                                method: 'POST',
                                waitMsgTarget: true,
                                waitTitle: Common.ApplicationName,
                                frame: false,
                                bodyPadding: 12,
                                bodyStyle: 'background-color:White;margin:0;',
                                bodyBorder: false,
                                border: 0,
                                autoScroll: true,
                                defaultType: 'textfield',
                                autoScroll: false,
                                fieldDefaults:
                                {
                                    labelAlign: 'left',
                                    labelWidth: 72,
                                    anchor: '100%',
                                    msgTarget: 'qtip',
                                    autoFitErrors: true,
                                    disabledCls: ''
                                },
                                items:
                                [
                                    {
                                        xtype: 'datefield',
                                        name: 'ApplicationDate',
                                        fieldLabel: '养护日期',
                                        emptyText: '养护日期',
                                        format: 'Y/m/d',
                                        disabled: false,
                                        allowBlank: false,
                                        listeners:
                                        {
                                            change: function (field, newValue, oldValue, eOpts)
                                            {
                                                //清除选择项目
                                                var quantity = field.up('form').down('#cboQuantityID');

                                                //重置数据
                                                quantity.reset();

                                                //清除现有数据
                                                store_master_quantity.removeAll(true);

                                                //判定是否选择了日期
                                                if (newValue)
                                                {

                                                    //加载数据
                                                    Common.AsyncLoadData(Common.MakeControllerUrl('MaintainQuantity', 'Reference'), { date: newValue.getTime() }, store_master_quantity);
                                                }
                                            }
                                        }
                                    },
                                    {
                                        xtype: 'combobox',
                                        name: 'QuantityID',
                                        itemId: 'cboQuantityID',
                                        fieldLabel: '养护编号',
                                        store: store_master_quantity,
                                        displayField: 'MaintainCode',
                                        valueField: 'QuantityID',
                                        queryMode: 'local',
                                        triggerAction: 'all',
                                        hideTrigger: false,
                                        forceSelection: true,
                                        disableKeyFilter: true,
                                        typeAhead: false,
                                        autocomplete: false,
                                        editable: true,
                                        allowBlank: false
                                    },
                                    {
                                        xtype: 'combobox',
                                        name: 'MaterialID',
                                        fieldLabel: '材料类型',
                                        store: store_master_material,
                                        displayField: 'Name',
                                        valueField: 'ID',
                                        queryMode: 'local',
                                        hideTrigger: false,
                                        forceSelection: true,
                                        typeAhead: true,
                                        autocomplete: true,
                                        allowBlank: false,
                                        enableKeyEvents: true,
                                        listeners:
                                        {
                                            select: function (field, records, eOpts)
                                            {
                                                //设置结果
                                                field.up('form').down('#txtUnit').setValue(records[0].data.Unit);
                                            }
                                        }
                                    },
                                    {
                                        xtype: 'textfield',
                                        name: 'Unit',
                                        disabled: true,
                                        itemId: 'txtUnit',
                                        fieldLabel: '材料单位',
                                        emptyText: '材料单位'
                                    },
                                    {
                                        xtype: 'numberfield',
                                        name: 'Quantity',
                                        itemId: 'txtQuantity',
                                        fieldLabel: '材料用量',
                                        emptyText: '材料用量',
                                        allowBlank: false,
                                        minValue: 0,
                                        decimalPrecision: 4,
                                        listeners:
                                        {
                                            change: function (field, newValue, oldValue, options)
                                            {
                                                //获得工作量
                                                var price = field.up('form').down('#txtPrice').getValue();

                                                //判断是否为数据
                                                if (!isNaN(price) && !isNaN(newValue))
                                                {
                                                    //计算结果
                                                    var value = Ext.util.Format.number(price * newValue, '0,000.00');

                                                    //设置结果
                                                    field.up('form').down('#txtAmount').setValue(value);
                                                }
                                            }
                                        }
                                    },
                                    {
                                        xtype: 'numberfield',
                                        name: 'Price',
                                        itemId: 'txtPrice',
                                        fieldLabel: '材料单价',
                                        emptyText: '材料单价',
                                        allowBlank: false,
                                        minValue: 0,
                                        decimalPrecision: 3,
                                        listeners:
                                        {
                                            change: function (field, newValue, oldValue, options)
                                            {
                                                //获得工作量
                                                var quantity = field.up('form').down('#txtQuantity').getValue();

                                                //判断是否为数据
                                                if (!isNaN(quantity) && !isNaN(newValue))
                                                {
                                                    //计算结果
                                                    var value = Ext.util.Format.number(quantity * newValue, '0,000.00');

                                                    //设置结果
                                                    field.up('form').down('#txtAmount').setValue(value);
                                                }
                                            }
                                        }
                                    },
                                    {
                                        xtype: 'textfield',
                                        itemId: 'txtAmount',
                                        fieldLabel: '小　　计',
                                        emptyText: '小计',
                                        disabled: true
                                    },
                                    {
                                        xtype: 'textareafield',
                                        name: 'Memo',
                                        fieldLabel: '备　　注',
                                        emptyText: '备注信息（最长200个字符）',
                                        maxLength: 200
                                    }
                                ],
                                buttons:
                                [
                                    {
                                        text: '确定',
                                        height: 26,
                                        margin: 3,
                                        handler: function ()
                                        {
                                            //获得表单对象
                                            var form = this.up('form').getForm();

                                            //检查数据是否合法
                                            if (form.isValid())
                                            {
                                                //提交数据
                                                form.submit
                                                (
                                                    {
                                                        url: Common.MakeAbsoluteUrl('Create'),
                                                        method: HttpMethod.Post,
                                                        scope: this.up('window'),
                                                        submitEmptyText: false,
                                                        waitTitle: '请稍候',
                                                        waitMsg: '正在保存数据...',
                                                        success: function (form, action)
                                                        {
                                                            //处理提交错误
                                                            if (Common.HandleFormError(form, action))
                                                            {
                                                                //重置数据
                                                                form.reset();
                                                                //隐藏窗体
                                                                this.hide();
                                                                //刷新数据
                                                                store.load();
                                                            }
                                                        },
                                                        failure: Common.HandleFormFailure
                                                    }
                                                );
                                            }
                                        }
                                    },
                                    {
                                        text: '取消',
                                        height: 26,
                                        margin: 3,
                                        handler: function ()
                                        {
                                            //获得表单对象
                                            var form = this.up('form').getForm();
                                            //重置数据
                                            form.reset();
                                            //隐藏窗体
                                            this.up('window').hide();
                                        }
                                    }
                                ]
                            }
                        ]
                    }
                 );
            }

            //显示窗体
            this.win_create.show();
        },

        //处理编辑按钮点击事件
        onEditClick: function ()
        {
            //获得数据存储对象
            var store = this.store;

            //获得选中的行
            var selection = this.getView().getSelectionModel().getSelection()[0];

            //判断是否选中行
            if (selection)
            {
                //判定窗体是否已经创建
                if (!this.win_edit)
                {
                    //创建窗体
                    this.win_edit = new Ext.Window
                    (
                        {
                            title: '编辑养护材料',
                            maximizable: false,
                            maximized: false,
                            width: 480,
                            height: 540,
                            autoScroll: false,
                            bodyBorder: false,
                            draggable: true,
                            isTopContainer: true,
                            modal: true,
                            resizable: false,
                            bodyPadding: 0,
                            closeAction: 'hide',
                            closable: false,
                            layout: 'fit',
                            fieldDefaults:
                            {
                                labelAlign: 'left',
                                labelWidth: 72,
                                anchor: '100%'
                            },
                            listeners:
                            {
                                //挂接隐藏事件
                                hide: function (win, options)
                                {
                                    //获得表单对象
                                    var form = win.down('form').getForm();
                                    //重置内容
                                    form.reset();
                                },
                                //挂接显示事件
                                show: function (win, options)
                                {
                                    //查询表单对象对象
                                    var form = win.down('form').getForm();

                                    //加载数据
                                    form.load
                                    (
                                        {
                                            url: Common.MakeAbsoluteUrl('Details?id=' + win.current_row.MaintainMaterialID),
                                            waitMsg: '数据加载中...',
                                            failure: function (form, action)
                                            {
                                                //关闭窗体
                                                win.hide();

                                                //处理错误
                                                Common.HandleFormFailure(form, action);
                                            }
                                        }
                                    );
                                }
                            },
                            items:
                            [
                                {
                                    xtype: 'form',
                                    method: 'POST',
                                    waitMsgTarget: true,
                                    waitTitle: Common.ApplicationName,
                                    frame: false,
                                    bodyPadding: 12,
                                    bodyStyle: 'background-color:White;margin:0;',
                                    bodyBorder: false,
                                    border: 0,
                                    autoScroll: true,
                                    defaultType: 'textfield',
                                    autoScroll: false,
                                    fieldDefaults:
                                    {
                                        labelAlign: 'left',
                                        labelWidth: 72,
                                        anchor: '100%',
                                        msgTarget: 'qtip',
                                        autoFitErrors: true,
                                        disabledCls: ''
                                    },
                                    items:
                                    [
                                        {
                                            xtype: 'hiddenfield',
                                            name: 'MaintainMaterialID',
                                            allowBlank: false
                                        },
                                        {
                                            xtype: 'datefield',
                                            name: 'ApplicationDate',
                                            fieldLabel: '养护日期',
                                            emptyText: '养护日期',
                                            format: 'Y/m/d',
                                            disabled: true,
                                            allowBlank: false
                                        },
                                        {
                                            xtype: 'hiddenfield',
                                            itemId: 'txtQuantityID',
                                            name: 'QuantityID'
                                        },
                                        {
                                            xtype: 'textfield',
                                            name: 'MaintainCode',
                                            itemId: 'txtMaintainCode',
                                            fieldLabel: '养护编号',
                                            emptyText: '养护编号',
                                            disabled: true
                                        },
                                        {
                                            xtype: 'combobox',
                                            name: 'MaterialID',
                                            itemId: 'cboMaterial',
                                            fieldLabel: '材料类型',
                                            store: store_master_material,
                                            displayField: 'Name',
                                            valueField: 'ID',
                                            queryMode: 'local',
                                            hideTrigger: false,
                                            forceSelection: true,
                                            typeAhead: true,
                                            autocomplete: true,
                                            allowBlank: false,
                                            listeners:
                                            {
                                                select: function (field, records, eOpts)
                                                {
                                                    //设置结果
                                                    field.up('form').down('#txtUnit').setValue(records[0].data.Unit);
                                                }
                                            }
                                        },
                                        {
                                            xtype: 'textfield',
                                            name: 'Unit',
                                            disabled: true,
                                            itemId: 'txtUnit',
                                            fieldLabel: '材料单位',
                                            emptyText: '材料单位'
                                        },
                                        {
                                            xtype: 'numberfield',
                                            name: 'Quantity',
                                            itemId: 'txtQuantity',
                                            fieldLabel: '材料用量',
                                            emptyText: '材料用量',
                                            allowBlank: false,
                                            minValue: 0,
                                            decimalPrecision: 4,
                                            listeners:
                                            {
                                                change: function (field, newValue, oldValue, options)
                                                {
                                                    //获得工作量
                                                    var price = field.up('form').down('#txtPrice').getValue();

                                                    //判断是否为数据
                                                    if (!isNaN(price) && !isNaN(newValue))
                                                    {
                                                        //计算结果
                                                        var value = Ext.util.Format.number(price * newValue, '0,000.00');

                                                        //设置结果
                                                        field.up('form').down('#txtAmount').setValue(value);
                                                    }
                                                }
                                            }
                                        },
                                        {
                                            xtype: 'numberfield',
                                            name: 'Price',
                                            itemId: 'txtPrice',
                                            fieldLabel: '材料单价',
                                            emptyText: '材料单价',
                                            allowBlank: false,
                                            minValue: 0,
                                            decimalPrecision: 3,
                                            listeners:
                                            {
                                                change: function (field, newValue, oldValue, options)
                                                {
                                                    //获得工作量
                                                    var quantity = field.up('form').down('#txtQuantity').getValue();

                                                    //判断是否为数据
                                                    if (!isNaN(quantity) && !isNaN(newValue))
                                                    {
                                                        //计算结果
                                                        var value = Ext.util.Format.number(quantity * newValue, '0,000.00');

                                                        //设置结果
                                                        field.up('form').down('#txtAmount').setValue(value);
                                                    }
                                                }
                                            }
                                        },
                                        {
                                            xtype: 'textfield',
                                            itemId: 'txtAmount',
                                            fieldLabel: '小　　计',
                                            emptyText: '小计',
                                            disabled: true
                                        },
                                        {
                                            xtype: 'textareafield',
                                            name: 'Memo',
                                            fieldLabel: '备　　注',
                                            emptyText: '备注信息（最长200个字符）',
                                            maxLength: 200
                                        }
                                    ],
                                    buttons:
                                    [
                                        {
                                            text: '确定',
                                            height: 26,
                                            margin: 3,
                                            handler: function ()
                                            {
                                                //获得窗体对象
                                                var form = this.up('form');

                                                //获得表单对象
                                                var formBase = form.getForm();

                                                //清除选择项目
                                                var cboQuantity = form.down('#cboQuantityID');

                                                //获得隐藏字段
                                                var txtQuantity = form.down('#txtQuantityID');

                                                //判断控件是否存在
                                                if (cboQuantity && txtQuantity)
                                                {
                                                    //设置隐藏字段的值
                                                    txtQuantity.setValue(cboQuantity.getValue());
                                                }

                                                //检查数据是否合法
                                                if (formBase.isValid())
                                                {
                                                    //提交数据
                                                    formBase.submit
                                                    (
                                                        {
                                                            url: Common.MakeAbsoluteUrl('Update'),
                                                            method: HttpMethod.Post,
                                                            scope: this.up('window'),
                                                            submitEmptyText: false,
                                                            waitTitle: '请稍候',
                                                            waitMsg: '正在保存数据...',
                                                            success: function (form, action)
                                                            {
                                                                //处理提交错误
                                                                if (Common.HandleFormError(form, action))
                                                                {
                                                                    //重置数据
                                                                    form.reset();
                                                                    //隐藏窗体
                                                                    this.hide();
                                                                    //刷新数据
                                                                    store.load();
                                                                }
                                                            },
                                                            failure: Common.HandleFormFailure
                                                        }
                                                    );
                                                }
                                            }
                                        },
                                        {
                                            text: '取消',
                                            height: 26,
                                            margin: 3,
                                            handler: function ()
                                            {
                                                //获得表单对象
                                                var form = this.up('form').getForm();
                                                //重置数据
                                                form.reset();
                                                //隐藏窗体
                                                this.up('window').hide();
                                            }
                                        }
                                    ]
                                }
                            ]
                        }
                    );
                }

                //设置当前行
                this.win_edit.current_row = selection.data;

                //显示窗体
                this.win_edit.show();
            }
        },

        //处理提交按钮点击事件
        onSubmitClick: function ()
        {
            //获得数据存储对象
            var store = this.store;

            //获得选中的行
            var selection = this.getView().getSelectionModel().getSelection();

            //判断是否选中行
            if (selection.length > 0)
            {

                //记录所有的编号
                var materials = [];

                //循环添加
                for (var index in selection)
                {
                    //添加记录
                    materials.push(selection[index].data.MaintainMaterialID);
                }

                //询问是否确定操作
                Ext.Msg.show
                (
                    {
                        title: '提交审核',
                        width: 320,
                        height: 240,
                        msg: '确定要将选中的养护材料提交审核吗?',
                        buttons: Ext.Msg.YESNO,
                        icon: Ext.Msg.QUESTION,
                        fn: function (button)
                        {
                            //判断是否确定删除 
                            if (button == 'yes')
                            {
                                //创建请求对象
                                Ext.Ajax.request
                                (
                                    {
                                        url: Common.MakeAbsoluteUrl('ExecuteSubmit'),
                                        method: HttpMethod.Post,
                                        params:
                                        {
                                            materials: materials, passed: true
                                        },
                                        callback: function (options, success, response)
                                        {
                                            //处理错误
                                            if (Common.HandleError(options, success, response))
                                            {
                                                //加载数据
                                                store.load();
                                            }
                                        }
                                    }
                                );
                            }
                        }
                    }
                );
            }
        }
    }
);

//挂接环境准备完毕事件
Ext.onReady
(
    function ()
    {
        //初始化快速提示
        Ext.QuickTips.init();

        //设置状态保存提供者（当前设置为Cookie）
        Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider', { path: _Current_ActionUrl }));

        //初始化附加验证类型
        Common.InitAdditionalValidation();

        //创建存储对象
        store_master_material = Ext.create
        (
            'Ext.data.Store',
            {
                fields: ['ID', 'Name', 'Unit'],
                data: master_material
            }
        );

        //创建存储对象
        store_master_quantity = Ext.create
        (
            'Ext.data.Store',
            {
                model: 'MaintainQuantityReferenceModel'
            }
        );

        //创建数据存储对象
        var store = Ext.create
        (
            'Ext.data.Store',
            {
                pageSize: 20,
                autoSync: true,
                autoLoad: true,
                root: 'data',
                remoteFilter: true,
                remoteSort: true,
                model: 'MaintainMaterialModel',
                proxy:
                {
                    type: 'ajax',
                    batchActions: false,
                    url: Common.MakeAbsoluteUrl('SubmitSelect'),
                    reader:
                    {
                        type: 'json',
                        root: 'data'
                    },
                    listeners:
                    {
                        exception: function (proxy, response, operation, options)
                        {
                            //处理错误
                            Common.HandleProxyError(proxy, response, operation, options);
                        }
                    }
                }
            }
        );

        //创建选择模型
        var selectionModel = Ext.create('Ext.selection.CheckboxModel');

        //创建表格
        Ext.create
        (
            'MaintainMaterial.Grid',
            {
                store: store,
                selModel: selectionModel,
                stateful: true,
                stateId: 'maintainmaterial-submit-state-grid',
                height: 600,
                width: '100%',
                id: 'maintainmaterial-grid',
                title: '',
                renderTo: 'data-grid',
                columnLines: true,
                viewConfig:
                {
                    stripeRows: true,
                    loadingText: '数据加载中...',
                    singleSelect: true
                },
                //创建分页工具栏
                bbar: Ext.create
                (
                    'Ext.PagingToolbar',
                    {
                        store: store,
                        displayInfo: true,
                        displayMsg: '第 {0} - 第 {1} 条记录，共 {2} 条记录',
                        emptyMsg: ''
                    }
                ),
                columns:
                [
                    {
                        text: '单位名称',
                        width: 160,
                        sortable: true,
                        align: 'left',
                        dataIndex: 'Organization',
                        hideable: false
                    },
                    {
                        text: '养护编号',
                        width: 80,
                        sortable: true,
                        align: 'left',
                        dataIndex: 'MaintainCode',
                        hideable: false
                    },
                    {
                        text: '状态',
                        width: 60,
                        sortable: true,
                        align: 'center',
                        dataIndex: 'State',
                        renderer: Common.RenderMaintainDataState
                    },
                    {
                        text: '审核意见',
                        xtype: 'templatecolumn',
                        tpl: '<a class="Comment" href="javascript:void(0);" onclick="javascript:return Common.ViewComment(this);" title="{Comment}">{Comment}</a> ',
                        width: 80,
                        sortable: false,
                        align: 'left',
                        dataIndex: 'Comment',
                        hideable: true
                    },
                    {
                        text: '材料类型',
                        width: 80,
                        sortable: true,
                        align: 'left',
                        dataIndex: 'Material'
                    },
                    {
                        text: '材料用量',
                        width: 160,
                        sortable: false,
                        align: 'right',
                        renderer: Common.RenderNumber3WithUnit,
                        dataIndex: 'Quantity'
                    },
                    {
                        text: '材料单价',
                        width: 80,
                        sortable: false,
                        align: 'right',
                        renderer: Ext.util.Format.numberRenderer('0,000.000'),
                        dataIndex: 'Price'
                    },
                    {
                        text: '小计',
                        width: 80,
                        sortable: false,
                        align: 'right',
                        renderer: Ext.util.Format.numberRenderer('0,000.00'),
                        dataIndex: 'Amount'
                    },
                    {
                        text: '养护日期',
                        width: 80,
                        sortable: true,
                        align: 'right',
                        renderer: Ext.util.Format.dateRenderer('Y/m/d'),
                        dataIndex: 'ApplicationDate'
                    },
                    {
                        text: '填报人',
                        width: 80,
                        sortable: true,
                        align: 'left',
                        dataIndex: 'Applicant'
                    },
                    {
                        text: '填报日期',
                        width: 80,
                        sortable: true,
                        align: 'right',
                        renderer: Ext.util.Format.dateRenderer('Y/m/d'),
                        dataIndex: 'CreateDate'
                    },
                    {
                        text: '延期填报',
                        width: 80,
                        sortable: true,
                        align: 'center',
                        renderer: renderGridReadonlyCheckBox,
                        dataIndex: 'IsDelay'
                    },
                    {
                        text: '备注',
                        xtype: 'templatecolumn',
                        tpl: '<span title="{Memo}">{Memo}</span> ',
                        width: 160,
                        minWidth: 160,
                        flex: 1,
                        sortable: false,
                        align: 'left',
                        dataIndex: 'Memo',
                        hideable: true
                    }
                ]
            }
        );

        $(window).bind
        (
            "resize",
            function ()
            {
                //调整表格宽度
                Common.AdjustGridWidth('maintainmaterial-grid', 'body_content');
            }
        );

        //调整表格宽度
        Common.AdjustGridWidth('maintainmaterial-grid', 'body_content');
    }
);
